<?php
include_only();

if(!empty($leave_group) and $leave_group=="yes")
{
mysql_query("DELETE FROM `teams` WHERE `id` = '$request_id'");
}

$user_information = get_user_info();
$request_user_id = $user_information['id'];

$requests = get_user_requests($request_user_id);
//view_array($requests);

$my_requests = "
<table style='width:100%;'>
<tr>
<td>subtitle</td>
<td style='width:20px'></td>
<td style='width:30px'></td>
</tr>
";

for ($i = 0; $i <= count($requests)-1; $i++) {
$subtitle = $requests[$i]['subtitle_id'];
$subtitle_info = get_subtitle_info($subtitle); 
$subtitle_name = $subtitle_info['title'];

$state = $requests[$i]['state'];
$request_id = $requests[$i]['id'];

if($state=='0'){$current_state="<img src='templates/".read_option('theme_folder')."/control/wait.png' title='waiting'>";}
if($state=='1'){$current_state="<img src='templates/".read_option('theme_folder')."/control/approve.png' title='approved'>";}
if($state=='-1'){$current_state="<img src='templates/".read_option('theme_folder')."/control/not_accepted.png' title='not approved'>";}

    $my_requests = $my_requests . "
	<tr>
	<td>".$subtitle_name."</td>
	<td style='width:20px'>".$current_state."</td>
	<td style='width:30px'>
	<form method='post' action='index.php'>
	<input type='image' src='templates/".read_option('theme_folder')."/control/leave.png' title='leave group'/>
	<input type='hidden' name='page' value='my_requests' />
	<input type='hidden' name='user_id' value='".$request_user_id."' />
	<input type='hidden' name='request_id' value='".$request_id."' />
	<input type='hidden' name='leave_group' value='yes' />
	</form>
	</td>
	</tr>
";
}


$my_requests = $my_requests . "
</table>
";
?>